package org.dtrd.modules.control.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.dtrd.common.constant.CommonConstant;
import org.dtrd.modules.control.entity.bean.TargetDetailInfo;

import java.io.Serializable;
import java.util.Date;

/**
 * 控制目标详情-所有子项
 *
 * @TableName dtrd_ent_rd_signin_target_detail
 */
@TableName(value = "dtrd_ent_rd_signin_target_detail")
@Data
public class DtrdEntRdSigninTargetDetail implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Integer dataId;

    /**
     * 方案ID
     */
    private Integer targetId;

    /**
     * 患者ID
     */
    private Integer patientId;

    /**
     * 项目类型：1-体质指数（BMI）,2-糖化血红蛋白（HbA1c）,3-空腹血糖（FBG）,4-餐后血糖（PBG）,5-舒张压/低压,6-收缩压/高压,7-总胆固醇（TC）,8-甘油三酯（TG）,9- 高密度脂蛋白（HDL）,10-低密度脂蛋白（LDL）
     */
    private Integer projectType;

    /**
     * 控制目标 低值
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED)
    private Float targetLow;

    /**
     * 当前值
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED)
    private Float value;

    /**
     * 诊断结果
     */
    private String result;

    /**
     * 当前值状态 0-正常 1-上升 2-下降
     */
    private Integer status;

    /**
     * 控制目标 高值
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED)
    private Float targetHigh;

    /**
     * 单位
     */
    private String unit;

    /**
     * 用户类型
     */
    private Integer userType;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 备注
     */
    @TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED)
    private String remark;

    /**
     *
     */
    private Integer isDel;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public DtrdEntRdSigninTargetDetail parseFromDTO(TargetDetailInfo dto) {
        this.setDataId(dto.getDataId());
        this.setTargetId(dto.getTargetId());
        this.setPatientId(dto.getPatientId());
        this.setProjectType(dto.getProjectType());
        this.setTargetLow(dto.getTargetLow());
        this.setTargetHigh(dto.getTargetHigh());
        this.setValue(dto.getValue());
        this.setResult(dto.getResult());
        this.setUnit(dto.getUnit());
        this.setUserType(dto.getUserType());
        return this;
    }

    public DtrdEntRdSigninTargetDetail buildWithParams(Integer patientId, Integer targetId) {
        this.targetId = targetId;
        this.patientId = patientId;
        return this;
    }

    public DtrdEntRdSigninTargetDetail init() {
        this.setUserType(1);
        this.setCreateTime(new Date());
        this.setIsDel(CommonConstant.DEL_FLAG_0);
        return this;
    }

    @Override
    public String toString() {
        return "DtrdEntRdSigninTargetDetail{" +
                "projectType=" + projectType +
                ", targetId=" + targetId +
                ", patientId=" + patientId +
                ", targetLow=" + targetLow +
                ", targetHigh=" + targetHigh +
                ", result='" + result +
                ", remark='" + remark +
                '}';
    }
}